# -*- coding: utf-8 -*-


import os
import uuid
import django
from datetime import datetime
from core.initialize import Initialize
from apps.sys.models import Menu, DictType, DictData

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "application.settings")
django.setup()


class Init(Initialize):

    def init_dict(self):
        dict_type = [
            
        ]
        dict_data = [
            
        ]
        self.save(DictType, dict_type, "字典类型")
        self.save(DictData, dict_data, "字典数据")

    def init_menu(self):
        """
        初始化菜单表-知识管理
        """
        dms = uuid.uuid4()
        dms_online = uuid.uuid4()
        dms_offline = uuid.uuid4()
        self.menu_dms_data = [
            {
                "dept_belong_id": self.dept_belong_id,
                "update_time": datetime.now(),
                "create_time": datetime.now(),
                "creator_id": self.creator_id,
                "id": dms,
                "name": "文档管理",
                "type": "M",
                "icon": "dms",
                "path": "/dms",
                "component": "Layout",
                "perms": None,
                "nesting": True,
                "redirect": "noRedirect",
                "parent_id": None,
                "sort": 5,
            },
            {
                "dept_belong_id": self.dept_belong_id,
                "update_time": datetime.now(),
                "create_time": datetime.now(),
                "creator_id": self.creator_id,
                "id": dms_online,
                "name": "在线文档",
                "type": "C",
                "icon": "online",
                "path": "online",
                "component": "dms/online/index",
                "perms": "dms:online:list",
                "parent_id": dms,
                "sort": 1,
            },
            {
                "dept_belong_id": self.dept_belong_id,
                "update_time": datetime.now(),
                "create_time": datetime.now(),
                "creator_id": self.creator_id,
                "id": dms_offline,
                "name": "离线文档",
                "type": "C",
                "icon": "offline",
                "path": "offline",
                "component": "dms/offline/index",
                "perms": "dms:offline:list",
                "parent_id": dms,
                "sort": 1,
            },
            
        ]
        self.save(Menu, self.menu_dms_data, "菜单表")

    def run(self):
        self.init_dict()
        self.init_menu()


def main(reset=False):
    Init(reset).run()
    pass


if __name__ == "__main__":
    main()
